package cn.trdu._07springaop.egaop1;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class OrderCheckAspect {
    @Before(value = "execution(public void cn.trdu._07springaop.egaop1.OrderServiceImpl.*(..))")
    public void beforeMethod(JoinPoint joinPoint){
        //获取订单数量
        int number = (int) joinPoint.getArgs()[0];
        if (number <= 0){
            throw new IllegalArgumentException("订单数量必须大于0");
        }
    }
}









